﻿using DotNet.Extensions;
using DotNet.JCore.Entity;
using DotNet.JCore.Service;
using DotNet.Web.Areas.AuthWeb.Controllers;
using System.Collections.Generic;
using System.Web.Mvc;

namespace DotNet.Web.Areas.Mobile.Controllers
{
    public class M_AuditstatisticsController : AuthController
    {
        private InspectorRegistrationSumService Service = new InspectorRegistrationSumService();
        private static string staticInspectorsName = "";
        public ActionResult Index(string InspectorsName,string startDate, string endDate)
        {
            if(startDate.IsEmpty())
            {
                startDate = System.DateTime.Now.ToShortDateString();
            }
            var list = Service.M_GetPageList(PageInfo(), startDate.ToDateTimeOrNull(), endDate.ToDateTimeOrNull(), InspectorsName);
            ViewBag.Count = list.Count.ToString();
            ViewBag.InspectorsName = InspectorsName;
            staticInspectorsName = InspectorsName;
            return View(list);         
        }
        [HttpPost]
        public ActionResult Index()
        {
            string InspectorsName = staticInspectorsName;
            string startDate = Request["startDate"];
            string endDate = Request["endDate"];
            if (startDate != string.Empty)
            {
                ViewBag.startDate = startDate;
            }
            if (endDate != string.Empty)
            {
                ViewBag.endDate = endDate;
            }
            string submit= Request["submit"];
            if (submit == "返回")
            {
                return RedirectToAction("home","M_login");
            }
            if (startDate.IsEmpty())
            {
                startDate = System.DateTime.Now.ToShortDateString();
            }
            var list = Service.M_GetPageList(PageInfo(), startDate.ToDateTimeOrNull(), endDate.ToDateTimeOrNull(), InspectorsName);
            ViewBag.Count = list.Count.ToString();
            ViewBag.InspectorsName = InspectorsName;
            return View(list);
        }


    }
}